#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
struct car{
    int d, v, a;
} a[N];
int b[N];
void Main(){
    int n, m, l, v;
    cin >> n >> m >> l >> v;
    int pd = 0;
    for(int i = 0; i < n; i ++){
        cin >> a[i].d >> a[i].v >> a[i].a;
        if(a[i].a < 0) pd = 1;
        else if(a[i].a > 0) pd = 2;
    }
    for(int i = 0; i < m; i ++) cin >> b[i];
    if(pd == 0){
        int f = 0;
        for(int i = 0; i < n; i ++){
            if(a[i].v > v && a[i].d <= b[m - 1]) f ++;
        }
        cout << f << ' ';
        if(f > 0) cout << m - 1 << endl;
        else cout << m << endl;
    }
    else if(pd == 1){
        int f = 0;
        for(int i = 0; i < n; i ++){
            if(sqrt(a[i].v * a[i].v + 2 * a[i].a * (b[m - 1] - a[i].d)) > v) f ++;
        }
        cout << f << ' ';
        if(f > 0) cout << m - 1 << endl;
        else cout << m << endl;
    }
    else{
        int f = 0;
        for(int i = 0; i < n; i ++){
            if(sqrt(a[i].v * a[i].v + 2 * a[i].a * (b[m - 1] - a[i].d)) > v) f ++;
        }
        cout << f << ' ';
        if(f > 0) cout << m - 1 << endl;
        else cout << m << endl;
    }
}
signed main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    cin >> t;
    while(t --){
        Main();
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
